<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script>

    // 类创建对象
    class Class {
        constructor(name, age) {
            this.name = name
            this.age = age
        };
        sex = "女";
        say = function () {
            console.log(this)
        }
    }

    const class1 = new Class("年级", 12);
    class1.say()

    // 等价于 var obj  = new Object()
    var obj = {
        name: "小明",
        age: 12,
        say: function () {
            console.log(this)
        },
    }
    obj.say()

    var student = new Object();
    student.name = "小明";
    student.say = function () {
        console.log(this)
    }
    student.say()

    // 构造函数
    function Teacher(name, say) {
        this.name = name;
        this.say = say
    }

    var tea = new Teacher("小明", function (){
        console.log(this)
    });

    tea.say()
</script>
</html>
